import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

public class ReadGsonSample {
    public static void main(String[] args) throws IOException {

        File file = new File(ReadGsonSample.class.getResource("/wu.json").getFile());

        String content = FileUtils.readFileToString(file);
/*
        Gson gson = new Gson();

        Diaosi diaosi = gson.fromJson(content, Diaosi.class);

        System.out.println(diaosi);*/




        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();

        DiaosiWithBirthday diaosiWithBirthday = gson.fromJson(content, DiaosiWithBirthday.class);

        System.out.println(diaosiWithBirthday.getBirthday().toLocaleString());

        System.out.println(diaosiWithBirthday.getMajor());

        System.out.println(diaosiWithBirthday.getMajor().getClass());

    }
}
